class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
char ch;
int s = strs.size(), n = strs[0].size();
        for(int i = 0; i < n; i++)
        {
             ch = strs[0][i];
            for(int j = 0; j < s; j++)
            {
                if(i >= strs[j].size() || strs[j][i] != ch)
                {
                    return strs[0].substr(0, i);
                }
            }
        }
        return strs[0].substr(0);
    }
};